package Opgave10_1;


import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeMap;
import java.util.TreeSet;

public class TextAnalyzer {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArrayList<String> text = new ArrayList<String>();
		text.addAll(Text.getTextAsLinkedList());
		System.out.println("Texten består af " + text.size() + " bidder");
		System.out.println("Text på plads 45: " + text.get(44));

		HashSet<String> hashy = new HashSet<String>();
		hashy.addAll(Text.getTextAsLinkedList());
		System.out.println("der er " + hashy.size() + " forskellige ord");

		TreeSet<String> sorty = new TreeSet<String>();
		sorty.addAll(Text.getTextAsLinkedList());
		for(String strings : sorty){
			System.out.println(strings);
		}

		// Sorts an arraylist and prints out the sorted items.
		Collections.sort(text);
		for(String strings : text){
			System.out.println(strings);
		}

		TreeMap<String, Integer> mapsy = new TreeMap<String, Integer>();
		for(String strings : text){
			if(mapsy.containsKey(strings)){
				mapsy.put(strings, mapsy.get(strings)+ 1);
			}
			else mapsy.put(strings, 1);	
		}
		
		System.out.println(mapsy.toString());

		
	



	}

}
